/*  1:   */ package org.jetbrains.jps.service.impl;
/*  2:   */ 
/*  3:   */

import org.jetbrains.jps.service.JpsServiceManager;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */ 
/* 11:   */ public class JpsServiceManagerImpl
/* 12:   */   extends JpsServiceManager
/* 13:   */ {
/* 14:27 */   private final ConcurrentHashMap<Class, Object> a = new ConcurrentHashMap(16, 0.75F, 1);
/* 15:28 */   private final ConcurrentHashMap<Class, List<?>> b = new ConcurrentHashMap(16, 0.75F, 1);
/* 16:   */   
/* 17:   */   public <T> T getService(Class<T> paramClass)
/* 18:   */   {
/* 19:33 */     Object localObject1 = this.a.get(paramClass);
/* 20:34 */     if (localObject1 == null)
/* 21:   */     {
/* 22:35 */       Iterator localIterator = ServiceLoader.load(paramClass, paramClass.getClassLoader()).iterator();
/* 23:36 */       if (!localIterator.hasNext()) {
/* 24:37 */         throw new ServiceConfigurationError("Implementation for " + paramClass + " not found");
/* 25:   */       }
/* 26:39 */       Object localObject2 = localIterator.next();
/* 27:40 */       if (localIterator.hasNext()) {
/* 28:41 */         throw new ServiceConfigurationError("More than one implementation for " + paramClass + " found: " + localObject2.getClass() + " and " + localIterator.next().getClass());
/* 29:   */       }
/* 30:45 */       localObject1 = this.a.putIfAbsent(paramClass, localObject2);
/* 31:46 */       if (localObject1 == null) {
/* 32:47 */         localObject1 = localObject2;
/* 33:   */       }
/* 34:   */     }
/* 35:50 */     return localObject1;
/* 36:   */   }
/* 37:   */   
/* 38:   */   public <T> Iterable<T> getExtensions(Class<T> paramClass)
/* 39:   */   {
/* 40:55 */     Object localObject1 = (List)this.b.get(paramClass);
/* 41:56 */     if (localObject1 == null)
/* 42:   */     {
/* 43:57 */       ServiceLoader localServiceLoader = ServiceLoader.load(paramClass, paramClass.getClassLoader());
/* 44:58 */       ArrayList localArrayList = new ArrayList();
/* 45:59 */       for (Object localObject2 : localServiceLoader) {
/* 46:60 */         localArrayList.add(localObject2);
/* 47:   */       }
/* 48:62 */       localObject1 = (List)this.b.putIfAbsent(paramClass, localArrayList);
/* 49:63 */       if (localObject1 == null) {
/* 50:64 */         localObject1 = localArrayList;
/* 51:   */       }
/* 52:   */     }
/* 53:68 */     return localObject1;
/* 54:   */   }
/* 55:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.service.impl.JpsServiceManagerImpl

 * JD-Core Version:    0.7.0.1

 */